package com.mvp.shq.washer.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;

import com.mvp.shq.washer.R;
import com.mvp.shq.washer.entity.shop.RefundReason;

import java.util.List;

/**
 * Created by Administrator on 2017/10/19.
 */

public class RefundReasonAdapter extends BaseAdapter {
    private Context context;
    private List<RefundReason> datas;

    public RefundReasonAdapter(Context mContext,List<RefundReason> list){
        context = mContext;
        datas = list;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.item_refund_reason, parent, false);
            holder = new ViewHolder();
            holder.name = (TextView)convertView.findViewById(R.id.tv_name);
            holder.checkBox = (CheckBox)convertView.findViewById(R.id.check);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }
        holder.name.setText(datas.get(position).getName());
        holder.checkBox.setChecked(datas.get(position).isSelect());
        return convertView;
    }

    class ViewHolder{
        private TextView name;
        private CheckBox checkBox;
    }
}
